{layout name="common/base" }
<div class="layui-form layuimini-form">
    <div class="spec-content">
        <div class="layui-form-item">
            <label class="layui-form-label required">规格名称</label>
            <div class="layui-input-block" style="width:375px;">
                <input type="text" name="name" lay-verify="required" lay-reqtext="名称不能为空" placeholder="请输入名称" value="" class="layui-input">
            </div>
        </div>
        <div class="spec-content-">

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required"></label>
            <div class="layui-input-block">
                <button type="button" class="layui-btn add-spec">添加规格</button>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="开启" checked="">
                <input type="radio" name="status" value="0" title="禁用">
            </div>
        </div>


    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>

<script>
    var url = '/admin/store.specs/add';
    add_edit(url);

    layui.use(['form'], function () {
        var $ = layui.$; //Tab的切换功能，切换事件监听等，需要依赖element模块
        $('.add-spec').on('click', function () {
            var html = '<div class="layui-form-item">'+
                            '<div class="layui-inline">'+
                                '<label class="layui-form-label">属性名</label>'+
                                '<div class="layui-input-inline">'+
                                    '<input type="text" name="specs_name[]" lay-verify="required" lay-reqtext="名称不能为空" placeholder="请输入名称" value="" class="layui-input">'+
                                '</div>'+
                            '</div>'+
                            '<div class="layui-inline">'+
                                '<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete" onclick="deletediv(this);">删除</a>'+
                            '</div>'+
                        '</div>';
            $('.spec-content-').append(html);
        });
    });
    function deletediv(a) {
        $(a).parent().parent().remove();
    }
</script>
